package com.example.springbootrabbitmq.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class Receiver {

    private static Logger log = LoggerFactory.getLogger(Receiver.class);

    @RabbitListener(queues = RabbitMQConfig.QUEUE)
    public void receiver(String message) {
        log.info("recevier message:"+message);
    }

    @RabbitListener(queues = RabbitMQConfig.TOPIC_QUEUE1)
    public void receiverTopic1(String message) {
        log.info("recevier topic queue1 message:"+message);
    }

    @RabbitListener(queues = RabbitMQConfig.TOPIC_QUEUE2)
    public void receiverTopic2(String message) {
        log.info("recevier topic queue2 message:"+message);
    }

    @RabbitListener(queues = RabbitMQConfig.FANOUT_QUEUE1)
    public void receiverFanout1(String message) {
        log.info("recevier fanout queue1 message:"+message);
    }

    @RabbitListener(queues = RabbitMQConfig.FANOUT_QUEUE2)
    public void receiverFanout2(String message) {
        log.info("recevier fanout queue2 message:"+message);
    }


    @RabbitListener(queues = RabbitMQConfig.HEADERS_QUEUE)
    public void receiverHeaders(byte[] message) {
        log.info("receiver headers message:"+new String(message));
    }
}